


cd && wget https://labex-ali-data.oss-us-west-1.aliyuncs.com/canal/canal.deployer-1.1.5.tar.gz
mkdir canal tar -zxvf canal.deployer-1.1.5.tar.gz -C canal
cd canal && ls
vim conf/canal.properties
and modify relevant configuration: Note: Replace YOUR-KAFKA-ADDR with your own Kafka connection address.
vim conf/example/instance.properties
to modify the relevant configuration:Note: Replace YOUR-RDS-ADDR with your RDS connection address.
bin/startup.sh
cd && wget https://labex-ali-data.oss-us-west-1.aliyuncs.com/canal/canal-0.0.1-SNAPSHOT.jar
Note: Replace YOUR-KAFKA-ADDR and YOUR-REDIS-ADDR with your Kafka and Redis connection addresses:
java -cp canal-0.0.1-SNAPSHOT.jar canal.SyncKafkaRedis YOUR-KAFKA-ADDR topic1 group1 YOUR-REDIS-ADDR Aliyun-test
You can see the data is being synchronized, and the output messages are consumed from Kafka.
Enter the following command to insert data into the user table:
insert into user values("19832", "name1", "ddsdfdfd", "addr1", "17138141002", "nickname1"); insert into user values("20122", "name2", "xdfdsafd", "addr2", "13877686321", "nickname2");
On command line 2, enter the following command to update the data with id = "19832":
update user set username = "nanzhao" where id = "19832";
On command line 3, enter the following command. You can see the data has been updated:
get 19832
On command line 2, enter the following command to delete the data with id = "19832":
delete from user where id = "19832";
On command line 3, enter the following command. You can see the Redis Key no longer exists, which indicates successful synchronization:
get 19832
Remotely log in to the "labex2" instance.
The default account name and password of the ECS instance are listed below:
Account name: root
Password: Aliyun-test
Run the following command to install apache2:
apt update && apt install -y apache2 python3-pip
pip3 install redis
mkdir /var/www/python
a2dismod mpm_event
a2enmod mpm_prefork cgi
vim /etc/apache2/sites-enabled/000-default.conf
to open the Apache configuration file. Replace all the content in the file with the code in Secction 7.1 of the Deployment Guide. Save the settings and exit.
vim /var/www/python/showRedis.py
to create a new file. Copy the code in Section 7.1 of the Deployment Guide and paste it to the file. Save the settings and exit.Note: Replace YOUR-REDIS-PUBLIC-DOMAIN with the address of your Redis instance.
chmod 755 /var/www/python/showRedis.py
service apache2 restart
Reach Alibaba Cloud experts for support
Contact Us